package com.comunicacion2;

import java.util.ArrayList;
import java.util.List;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.net.wifi.ScanResult;
import android.net.wifi.WifiManager;
import android.os.Handler;
import android.os.Message;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;

public class ScanRedesWifi extends BroadcastReceiver {
	
	private Handler h;
	private WifiManager wifi;
	
	public ScanRedesWifi(Handler h, WifiManager wifi) {
		super();
		this.h = h;
		this.wifi = wifi;
	}

	@Override
	public void onReceive(Context arg0, Intent arg1) {
		
	    List<ScanResult> results = wifi.getScanResults();
	    String[] namesArray = new String[results.size()];
	    
	    //for(ScanResult result : results){
	    for(int i=0;i<results.size();i++){
	    	namesArray[i]=results.get(i).SSID;
	    }
	    
		Message m=new Message();
		m.obj= namesArray;
		h.sendMessage(m);

	}

}
